package com.sea.task;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.sea.domain.Person;

import java.io.File;
import java.io.IOException;

public class JsonFileReader {
    public Person readJsonFromFile() {
        ObjectMapper objectMapper = new ObjectMapper();

        try {
            Person person = objectMapper.readValue(new File("person.json"), Person.class);
            System.out.println("JSON文件读取成功！");
            return person;
        } catch (IOException e) {
            System.out.println("JSON文件读取失败：" + e.getMessage());
            return null;
        }
    }
}
